﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using GISEntity;

namespace SLServiceLibrary
{
    //DBServer连接对象
    #region
    ///测试用例
    public class test
    {
        public double getvalue(string cityName, DateTime Time)
        {
            double value = 0;
            using (HnMapEntities database = new HnMapEntities())
            {
                 var queryResult1 = from first in database.AGRICULTURALs
                                    where (first.CITYNAME.Equals(cityName) && first.TIME.Equals(Time))
                                    select first.FARMINGVALUE;
                 value = Convert.ToDouble(queryResult1.Single());
 
            }
            Console.WriteLine(value);
            Console.WriteLine("到底是谁");
            return value;
        }
    }

    ///测试用例
    #endregion
    public class IndustrySignleValue//所选产业在所选地区的产值
    {
        private Server dbServer = new Server();
        public decimal GetIndustrySignleValue(string cityName, string countyName, DateTime Time, string industryTypeName, String industryType)
        {

            decimal value = 0;
            //decimal value2 = 0;
            int industrytype = 0;
            int industrytypename = 0;
            IndusryType it = new IndusryType();
            industrytype = it.GetIndustryType(industryType);
            industrytypename = it.GetIndustryName(industryTypeName);

            using (HnMapEntities database = new HnMapEntities(dbServer.GetConnectString()))
            {
                switch (industrytypename)
                {
                    case 1://从AGRICULTURAL表查询
                        #region
                        {
                            switch (industrytype)
                            {
                                //case 9:
                                //    {

                                //        var queryResult1 = from first in database.AGRICULTURALs
                                //                           where (first.CITYNAME.Equals(cityName) && first.TIME.Equals(Time))
                                //                           select first.AGRVALUE;
                                //        value = Convert.ToDouble(queryResult1.Single());
                                //    }
                                //    break;
                                case 10:
                                    {

                                        var queryResult2 = from first in database.AGRICULTURALs
                                                           where (first.CITYNAME.Equals(cityName) && first.TIME.Equals(Time))
                                                           select first.FARMINGVALUE;
                                        //value = Convert.ToDouble(queryResult2.Single());
                                        value = queryResult2.Single();
                                    }
                                    break;
                                case 11:
                                    {

                                        var queryResult3 = from first in database.AGRICULTURALs
                                                           where (first.CITYNAME.Equals(cityName) && first.TIME.Equals(Time))
                                                           select first.FORESTYVALUE;
                                       // value = Convert.ToDouble(queryResult3.Single());
                                        value = queryResult3.Single();
                                    }
                                    break;
                                case 12:
                                    {

                                        var queryResult4 = from first in database.AGRICULTURALs
                                                           where (first.CITYNAME.Equals(cityName) && first.TIME.Equals(Time))
                                                           select first.HUSBANDRYVALUE;
                                        //value = Convert.ToDouble(queryResult4.Single());
                                        value = queryResult4.Single();
                                    }
                                    break;
                                case 13:
                                    {

                                        var queryResult5 = from first in database.AGRICULTURALs
                                                           where (first.CITYNAME.Equals(cityName) && first.TIME.Equals(Time))
                                                           select first.FISHERYVALUE;
                                       // value = Convert.ToDouble(queryResult5.Single());
                                        value = queryResult5.Single();
                                    }
                                    break;

                                case 7:
                                    {
                                        var queryResult6 = from first in database.AGRICULTURALs
                                                           where (first.CITYNAME.Equals(cityName) && first.TIME.Equals(Time))
                                                           select first.SERVICEVALUE;
                                       // value = Convert.ToDouble(queryResult6.Single());
                                        value = queryResult6.Single();
                                    }
                                    break;

                            }

                        }
#endregion
                        break;

                    case 2://从COUNTYINDUSTRY查询
                        #region
                        {

                            switch (industrytype)
                            {
                                case 2:
                                    {

                                        var queryResult1 = from first in database.COUNTYINDUSTRies
                                                           where (first.COUNTYNAME.Equals(countyName) && first.TIME.Equals(Time))
                                                           select first.INDUSTRYVALUE;
                                        //value = Convert.ToDouble(queryResult1.Single());
                                        value = queryResult1.Single();

                                    }
                                    break;
                                case 3:
                                    {
                                        Console.WriteLine("1111111");
                                       var queryResult2
                                         = from first in database.COUNTYINDUSTRies
                                           where (first.COUNTYNAME.Equals(countyName) && first.CITYNAME.Equals(cityName) && first.TIME.Equals(Time))
                                                           select first.BUILDINGVALUE;
                                        //value = Convert.ToDouble(queryResult2);
                                       value = queryResult2.Single();
                                    }
                                    break;
                                case 4:
                                    {

                                        var queryResult4 = from first in database.COUNTYINDUSTRies
                                                           where (first.COUNTYNAME.Equals(countyName) && first.TIME.Equals(Time))
                                                           select first.TRANSPORTVALUE;
                                        //value = Convert.ToDouble(queryResult4.Single());
                                        value = queryResult4.Single();
                                    
                                    }
                                    break;
                                case 5:
                                    {

                                        var queryResult5 = from first in database.COUNTYINDUSTRies
                                                           where (first.COUNTYNAME.Equals(countyName) && first.TIME.Equals(Time))
                                                           select first.RETAILVALUE;
                                        //value = Convert.ToDouble(queryResult5.Single());
                                        value = queryResult5.Single();
                                    }
                                    break;
                                case 6:
                                    {

                                        var queryResult6 = from first in database.COUNTYINDUSTRies
                                                           where (first.COUNTYNAME.Equals(countyName) && first.TIME.Equals(Time))
                                                           select first.ESTATEVALUE;
                                        //value = Convert.ToDouble(queryResult6.Single());
                                        value = queryResult6.Single();
                                    }
                                    break;
                                case 7:
                                    {

                                        var queryResult7 = from first in database.COUNTYINDUSTRies
                                                           where (first.COUNTYNAME.Equals(countyName) && first.TIME.Equals(Time))
                                                           select first.SERVICEVALUE;
                                       // value = Convert.ToDouble(queryResult7.Single());
                                        value = queryResult7.Single();
                                    }
                                    break;
                                case 8:
                                    {

                                        var queryResult8 = from first in database.COUNTYINDUSTRies
                                                           where (first.COUNTYNAME.Equals(countyName) && first.TIME.Equals(Time))
                                                           select first.TOURISMVALUE;
                                        //value = Convert.ToDouble(queryResult8.Single());
                                        value = queryResult8.Single();
                                    }
                                    break;
                            }
                        }
#endregion
                        break;

                    case 3://从INDUSTRY表查询
                        #region
                        {
                            switch (industrytype)
                            {
                                case 1:
                                    {
                                        var queryResult1 = from first in database.INDUSTRies
                                                           where (first.CITYNAME.Equals(cityName) && first.TIME.Equals(Time))
                                                           select first.FIANCEVALUE;
                                        value =queryResult1.Single();
                                    }
                                    break;
                                case 2:
                                    {
                                        var queryResult2 = from first in database.INDUSTRies
                                                           where (first.CITYNAME.Equals(cityName) && first.TIME.Equals(Time))
                                                           select first.INDUSTRYVALUE;
                                        value = queryResult2.Single();
                                        //value = Convert.ToDouble(queryResult2.Single());
                                    }
                                    break;
                                case 3:
                                    {
                                        var queryResult3 = from first in database.INDUSTRies
                                                           where (first.CITYNAME.Equals(cityName) && first.TIME.Equals(Time))
                                                           select first.BUILDINGVALUE;
                                        //value = Convert.ToDouble(queryResult3.Single());
                                        value = queryResult3.Single();

                                    }
                                    break;
                                case 4:
                                    {
                                        var queryResult4 = from first in database.INDUSTRies
                                                           where (first.CITYNAME.Equals(cityName) && first.TIME.Equals(Time))
                                                           select first.TRANSPORTVALUE;
                                        //value = Convert.ToDouble(queryResult4.Single());
                                        value = queryResult4.Single();
                                    }
                                    break;
                                case 5:
                                    {
                                        var queryResult5 = from first in database.INDUSTRies
                                                           where (first.CITYNAME.Equals(cityName) && first.TIME.Equals(Time))
                                                           select first.RETAILVALUE;
                                        //value = Convert.ToDouble(queryResult5.Single());
                                        value = queryResult5.Single();
                                    }
                                    break;
                                case 6:
                                    {
                                        var queryResult6 = from first in database.INDUSTRies
                                                           where (first.CITYNAME.Equals(cityName) && first.TIME.Equals(Time))
                                                           select first.ESTATEVALUE;
                                        //value = Convert.ToDouble(queryResult6.Single());
                                        value = queryResult6.Single();
                                    }
                                    break;
                                case 7:
                                    {
                                        var queryResult7 = from first in database.INDUSTRies
                                                           where (first.CITYNAME.Equals(cityName) && first.TIME.Equals(Time))
                                                           select first.SERVICEVALUE;
                                       // value = Convert.ToDouble(queryResult7.Single());
                                        value = queryResult7.Single();
                                    }
                                    break;
                                case 8:
                                    {
                                        var queryResult8 = from first in database.INDUSTRies
                                                           where (first.CITYNAME.Equals(cityName) && first.TIME.Equals(Time))
                                                           select first.TOURISMVALUE;
                                        //value = Convert.ToDouble(queryResult8.Single());
                                        value = queryResult8.Single();
                                    }
                                    break;

                            }
                        }
#endregion
                        break;
                }
            }
            //Console.WriteLine(wc);
            Console.WriteLine("到底是");
            return value;
        }

    }
}
